home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_08_05 / 8n05027a < prev    next >
Text File  |  1990-04-17  |  902b  |  42 lines

  1. *****Listing 2*****
  2.  
  3. #include <stdio.h>
  4.  
  5. void f(long [][5]);
  6.  
  7. main()
  8. {
  9.         static long a[3][5] = {
  10.                 { 1, 2, 3, 4, 5},
  11.                 { 6, 7, 8, 9,10},
  12.                 {11,12,13,14,15}
  13.         };
  14.  
  15.         f(a);
  16. }
  17.  
  18. void f(long a[][5])
  19. {
  20.         printf("a[0][2] = %2d\n", a[0][2]);
  21.         printf("a[1][0] = %2d\n", a[1][0]);
  22.         printf("a[2][4] = %2d\n", a[2][4]);
  23.  
  24.         printf("sizeof(long)    = %lu\n",
  25.                 (unsigned long)sizeof(long));
  26.         printf("sizeof(long *)  = %lu\n",
  27.                 (unsigned long)sizeof(long *));
  28.         printf("sizeof(a)       = %lu\n",
  29.                 (unsigned long)sizeof(a));
  30.         printf("sizeof(*a)      = %lu\n",
  31.                 (unsigned long)sizeof(*a));
  32. }
  33.  
  34. a[0][2] =  3
  35. a[1][0] =  6
  36. a[2][4] = 15
  37. sizeof(long)    = 4
  38. sizeof(long *)  = 2
  39. sizeof(a)       = 2
  40. sizeof(*a)      = 20
  41.  
  42.